using System;
using PluginFrame;

namespace PcrExperimentProject
{
	[Serializable]
	public class MeltingSegment : AmplificationSegment, IMeltingSegment, ISegment
	{
		protected double mStartDegree;

		protected double mStopDegree;

		protected string mHoldTime;

		protected double mStepInterval;

		protected double mRate;

		public double StepInterval
		{
			get
			{
				return mStepInterval;
			}
			set
			{
				mStepInterval = value;
			}
		}

		public double Rate
		{
			get
			{
				return mRate;
			}
			set
			{
				mRate = value;
			}
		}

		public double StartDegree
		{
			get
			{
				return mStartDegree;
			}
			set
			{
				mStartDegree = value;
			}
		}

		public double StopDegree
		{
			get
			{
				return mStopDegree;
			}
			set
			{
				mStopDegree = value;
			}
		}

		public string HoldTime
		{
			get
			{
				return mHoldTime;
			}
			set
			{
				mHoldTime = value;
			}
		}

		public MeltingSegment()
		{
		}

		public override string ToString()
		{
			return mName;
		}

		public int CalculateMeltingCycle()
		{
			if (mStepInterval > 0.0)
			{
				mCycle = Convert.ToInt32((mStopDegree - mStartDegree + mStepInterval) / mStepInterval);
			}
			else
			{
				mCycle = 0;
			}
			return mCycle;
		}

		public MeltingSegment(int index)
		{
			mIndex = index;
			mIsAvailable = false;
			mName = "Melting";
		}

		public new bool IsEqual(ISegment segment)
		{
			IMeltingSegment meltingSegment = segment as IMeltingSegment;
			if (meltingSegment == null)
			{
				return false;
			}
			if (mIsAvailable != meltingSegment.IsAvailable)
			{
				return false;
			}
			if (!mIsAvailable)
			{
				return true;
			}
			if (mStartDegree != meltingSegment.StartDegree)
			{
				return false;
			}
			if (mStopDegree != meltingSegment.StopDegree)
			{
				return false;
			}
			if (mHoldTime != meltingSegment.HoldTime)
			{
				return false;
			}
			if (mStepInterval != meltingSegment.StepInterval)
			{
				return false;
			}
			if (mRate != meltingSegment.Rate)
			{
				return false;
			}
			return true;
		}
	}
}
